import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '人员',
    align: "center",
    sorter: true,
    dataIndex: 'outsourcePersonAccountId_dictText'
  },
  {
    title: '原订单编号',
    align: "center",
    sorter: true,
    dataIndex: 'oldOrderNo'
  },
  {
    title: '订单编号',
    align: "center",
    sorter: true,
    dataIndex: 'orderNo'
  },
  {
    title: '合同开始时间',
    align: "center",
    sorter: true,
    dataIndex: 'contractStartTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '合同结束时间',
    align: "center",
    sorter: true,
    dataIndex: 'contractEndTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '入项时间',
    align: "center",
    sorter: true,
    dataIndex: 'entryTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '离项时间',
    align: "center",
    sorter: true,
    dataIndex: 'departureTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '备注',
    align: "center",
    dataIndex: 'comments'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "人员",
    field: 'outsourcePersonAccountId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_outsource_person_account,real_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "订单编号",
    field: 'orderNo',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "合同开始时间",
    field: "contractStartTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "合同结束时间",
    field: "contractEndTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "入项时间",
    field: "entryTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "离项时间",
    field: "departureTime",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '人员',
    field: 'outsourcePersonAccountId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_outsource_person_account,real_name,id"
    },
    dynamicDisabled: true
  },
  {
    label: '原订单编号',
    field: 'oldOrderNo',
    component: 'Input',
    dynamicDisabled: true
  },
  {
    label: '订单编号',
    field: 'orderNo',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入订单编号!'},
             ];
    },
  },
  {
    label: '合同开始时间',
    field: 'contractStartTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入合同开始时间!'},
             ];
    },
  },
  {
    label: '合同结束时间',
    field: 'contractEndTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入合同结束时间!'},
             ];
    },
  },
  {
    label: '入项时间',
    field: 'entryTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入入项时间!'},
             ];
    },
  },
  {
    label: '离项时间',
    field: 'departureTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入离项时间!'},
             ];
    },
  },
  {
    label: '备注',
    field: 'comments',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  outsourcePersonAccountId: {title: '人员',order: 0,view: 'sel_search', type: 'string',dictTable: "tm_outsource_person_account", dictCode: 'id', dictText: 'real_name',},
  oldOrderNo: {title: '原订单编号',order: 1,view: 'text', type: 'string',},
  orderNo: {title: '订单编号',order: 2,view: 'text', type: 'string',},
  contractStartTime: {title: '合同开始时间',order: 3,view: 'date', type: 'string',},
  contractEndTime: {title: '合同结束时间',order: 4,view: 'date', type: 'string',},
  entryTime: {title: '入项时间',order: 5,view: 'date', type: 'string',},
  departureTime: {title: '离项时间',order: 6,view: 'date', type: 'string',},
  comments: {title: '备注',order: 7,view: 'textarea', type: 'string',},
};
